package com.goldgov;

import static springfox.documentation.builders.PathSelectors.regex;

import java.util.ArrayList;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.http.ResponseEntity;

import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@SpringBootApplication
@EnableSwagger2
public class Application {

	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}
	
	@Bean
	public ApiInfo apiInfo() {
		return new ApiInfo("代码生成器", 
				"代码生成器", 
				"1.0", 
				"", 
				new Contact("刘海刚","",""), 
				"", 
				"", 
				new ArrayList<>()
		);
	}
	
	@Bean
	public Docket build(ApiInfo apiInfo) {
		return new Docket(DocumentationType.SWAGGER_2).groupName("Code")
				.genericModelSubstitutes(ResponseEntity.class)
				.useDefaultResponseMessages(true)
				.forCodeGeneration(false)
				.select().paths(regex("/code.*"))
				.build()
				.apiInfo(apiInfo);
	}
}
